using System;
using System.Collections.Generic;
using System.Text;

namespace miciv.Rendering
{
    public class ManagedIndexBuffer<I> where I : struct
    {
        protected IndexBufferManager<I> m_ibManager;
        protected I[] m_indices;
        protected int m_sIndexCount;
        protected int m_sOffset;
        protected bool m_bIsDirty;

        public I[] Indices
        {
            get
            {
                return this.m_indices;
            }
            set
            {
                if (value != this.m_indices)
                {
                    this.m_indices = value;
                    this.IsDirty = true;
                }
            }
        }

        public int IndexCount
        {
            get
            {
                return this.m_sIndexCount;
            }
            set
            {
                if (value != this.m_sIndexCount)
                {
                    this.m_sIndexCount = value;
                    this.IsDirty = true;
                }
            }
        }

        public int Offset
        {
            get
            {
                return this.m_sOffset;
            }
            set
            {
                if (value != this.m_sOffset)
                {
                    this.m_sOffset = value;
                    this.IsDirty = true;
                }
            }
        }

        public bool IsDirty
        {
            get
            {
                return this.m_bIsDirty;
            }
            set
            {
                this.m_bIsDirty = value;
                this.m_ibManager.IsDirty |= value;
            }
        }

        public ManagedIndexBuffer(IndexBufferManager<I> _manager)
        {
            this.m_ibManager = _manager;
            this.m_sOffset = -1;
            this.m_sIndexCount = 0;
            this.m_indices = null;
        }
    }
}
